package bit1;

import java.util.Arrays;
import java.util.Scanner;
class Test1 {
    public static void hello() {
        System.out.println("hello");
    }
}
class Test {
    public int aMethod() {
        int i = 0;
        i++;
        return i;
    }
}
class Person{
    private String name = "Person";
    int age=0;

    public String getName() {
        return name;
    }
}
class A{
    int a;
    public A(int a){
        this.a=a;
    }
}
class Test3{

    public String toString() {

        System.out.print("aaa");

        return "bbb";

    }

}

    public class home1 extends Person{
        private int count;
        public static void main(String[] args) {

            System.out.println(new Test3());
        }
        public static void main18(String[] args) {

            home1 test=new home1(88);

            System.out.println(test.count);

        }

        home1(int a) {

            count=a;

        }
        static boolean Paddy;
        private String grade;
        private static int x = 100;// 2
//        public static void main16(String args[]) {// 3
//            home1 hsl = new home1();// 4
//            hsl.x++;// 5
//            home1 hs2 = new home1();// 6
//            hs2.x++;// 7
//            hsl = new home1();// 8
//            hsl.x++;// 9
//            home1.x--;// 10
//            System.out.println(" x=" + x);// 11
//        }
//        public static void main15(String[] args){
//            Person p = new home1();
//            System.out.println(p.getName());
//            home1 s=(home1)p;
//            System.out.println(s.grade);
//        }
        public static void main14(String args[]){
            System.out.println(Paddy);
        }
        public static void main13(String[] args) {
            Test test = new Test();
            test.aMethod();
            int j = test.aMethod();
            System.out.println(j);
        }
    public static void main12(String[] args) {
        String s="4";
        System.out.println("s="+s);
    }
    public static void main11(String[] args) {
        Test1 test1=null;
        test1.hello();
    }
    public static String toString(int[] a) {
        String str="[";
        for (int i = 0; i < a.length; i++) {
            if (i==0){
                str=str+a[i];
            }
            else{
                str=str+","+a[i];
            }
        }
        str+="]";
        return str;
    }

    public static void main10(String[] args) {
        int a[]={1,2,3};
        String str=toString(a);
        System.out.println(str);
    }
    public static int[] copyOf(int[] a){
        int b[]=new int[a.length];
        b=a.clone();
        return b;
    }
    public static void main9(String[] args) {
        int a[]={1,2,3,4,5,6,7,8,9,10,12,13,45,46};
        int[] b=copyOf(a);
        String str= Arrays.toString(b);
        System.out.println(str);
    }
    public static void main8(String[] args) {
        Scanner in=new Scanner(System.in);
        int a[]={1,2,3,4,5,6,7,8,9,10,12,13,45,46};
        int left=0,mid=0,i;
        int right=a.length-1;
        int k=in.nextInt();
        for (i = 0; i <a.length; i++) {
            mid=(left+right)/2;
            if(a[mid]<k){
                left=mid+1;
            }
            else if(a[mid]>k){
                right=mid-1;
            }
            else if(a[mid]==k){
                System.out.println(mid);
                break;
            }
        }
        if(i>=a.length){
            System.out.println("该数组没有该数字");
        }
    }
    public static void main7(String[] args) {
        int a[]={1,2,3,5,8,9,6,5};
        int i;
        if(a.length>=3){
            if (a[0]<a[1]){
                for (i = 1; i <=a.length-1; i++) {
                    if(a[i-1]>a[i]){
                        System.out.println("该数组不是有序递增");
                        break;
                    }
                }
                if (i>=a.length) {
                    System.out.println("该数组有序递增");
                }
            }
            else {
                for (i = 1; i <=a.length-1; i++) {
                    if(a[i-1]<a[i]){
                        System.out.println("该数组不是有序递减");
                        break;
                    }
                }
                if (i>=a.length) {
                    System.out.println("该数组有序递减");
                }
            }
        }
        else{
            System.out.println("该数组为有序");
        }
    }
    public static void main6(String[] args) {
        int arr[]={5,8,9,7,5,6,2,5,7,8,8,8,8,5,6,4,65};
        for (int i = 0; i < arr.length; i++) {
            for (int j = 1; j <=arr.length-1-i; j++) {
                if(arr[j-1]>arr[j]){
                    int tmp=arr[j-1];
                    arr[j-1]=arr[j];
                    arr[j]=tmp;
                }
            }
        }
        for (int a:arr) {
            System.out.print(a+" ");
        }
    }
    public static void main5(String[] args) {
        int a[]=new int[100];
        for (int i = 0; i <a.length; i++) {
            a[i]=i+1;
            System.out.print(a[i]+" ");
        }
    }
    public static void printArray(int[] a){
        for (int i = 0; i < a.length; i++) {
            System.out.print(a[i]+" ");
        }
    }
    public static void main4(String[] args) {
        int []a={1,2,3,4,5,6,7,8,9};
        printArray(a);
    }
    public static int[] transform(int[] a){
        for (int i = 0; i < a.length; i++) {
            a[i]*=2;
        }
        return a;
    }
    public static void main3(String[] args) {
        int []a={1,2,3};
        int []b=transform(a);
        for (int i = 0; i < b.length; i++) {
            System.out.print(b[i]+" ");
        }
    }
    public static int numSum(int[] a){
        int sum=0;
        for (int i = 0; i < a.length; i++) {
            sum+=a[i];
        }
        return sum;
    }
    public static void main2(String[] args) {
        Scanner in=new Scanner(System.in);
        int a[]={5,6,8,9,7,56,2,4,7,5,3};
        System.out.println(numSum(a));
    }
    public static int avg(int[] a){
        int sum=0;
        for (int i = 0; i < a.length; i++) {
            sum+=a[i];
        }
        return sum/a.length;
    }
    public static void main1(String[] args) {
        Scanner in=new Scanner(System.in);
        int a[]={5,6,8,9,7,56,2,4,7,5,3};
        System.out.println(avg(a));
    }
}
